<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">

    Sub OK_Click(sender As Object, e As EventArgs)
        if Page.isValid then
    
            Dim datade as String
            Dim vet = de.Text.Split("/")
            datade = vet(1) & "/" & vet(0) & "/" & vet(2)
    
            Dim dataate as String
            vet = ate.Text.Split("/")
            dataate = vet(1) & "/" & vet(0) & "/" & vet(2)
    
    
            Dim cnn As OleDbConnection
            Dim cmd As OleDbCommand
    
            cnn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\zt\zt.mdb;Persist Security Info=False")
    
            cmd = New OleDbCommand("select pedido.id, total, cliente.razaosocial, transportadora.razaosocial, data, pecas from pedido, cliente, fabrica, transportadora where pedido.idfabrica = 26 and pedido.idcliente=cliente.id and fabrica.id=pedido.idfabrica and transportadora.id=pedido.idtransportadora and data >= #" & datade & "# and data <= #" & dataate & "# order by data desc, pedido.id desc", cnn)
    
            cnn.Open()
            MyDataGrid.DataSource=cmd.ExecuteReader(CommandBehavior.CloseConnection)
            MyDataGrid.DataBind()
            cnn.close()
        end if
    End Sub

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <p align="center">
        </p>
        <h3 align="center">Pedidos - Bordados Eliane Ltda.
        </h3>
        <p>
        </p>
        <hr />
        <p>
        </p>
        <p>
            <table align="center">
                <tbody>
                    <tr>
                        <td>
                            Data inicial:</td>
                        <td>
                            <asp:TextBox id="de" runat="server"></asp:TextBox>
                        </td>
                        <td>
                            <asp:RangeValidator id="RangeValidator1" runat="server" ErrorMessage="*" ControlToValidate="de" Type="Date" MinimumValue="01/01/2003" MaximumValue="12/12/2099"></asp:RangeValidator>
                            <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ErrorMessage="*" ControlToValidate="de"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Data final:</td>
                        <td>
                            <asp:TextBox id="ate" runat="server"></asp:TextBox>
                        </td>
                        <td>
                            <asp:RangeValidator id="RangeValidator3" runat="server" ErrorMessage="*" ControlToValidate="ate" Type="Date" MinimumValue="01/01/2003" MaximumValue="12/12/2099"></asp:RangeValidator>
                            <asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ErrorMessage="*" ControlToValidate="ate"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <p>
                                <asp:Button id="OK" onclick="OK_Click" runat="server" Text="OK"></asp:Button>
                            </p>
                        </td>
                        <td>
                        </td>
                    </tr>
                </tbody>
            </table>
        </p>
        <hr />
        <p>
            &nbsp;<asp:DataGrid id="MyDataGrid" runat="server" AutoGenerateColumns="False" Font-Names="Tahoma" Font-Size="Small" HorizontalAlign="Center" CellPadding="3">
                <HeaderStyle font-bold="True" horizontalalign="Center" forecolor="White" backcolor="Gray"></HeaderStyle>
                <PagerStyle position="TopAndBottom"></PagerStyle>
                <Columns>
                    <asp:HyperLinkColumn DataNavigateUrlField="id" DataNavigateUrlFormatString="pedidoimprimir.aspx?id={0}" DataTextField="id" HeaderText="N&#250;mero"></asp:HyperLinkColumn>
                    <asp:BoundColumn DataField="data" HeaderText="Data" DataFormatString="{0:d}"></asp:BoundColumn>
                    <asp:BoundColumn DataField="cliente.razaosocial" HeaderText="Cliente"></asp:BoundColumn>
                    <asp:BoundColumn DataField="transportadora.razaosocial" HeaderText="Transportadora"></asp:BoundColumn>
                    <asp:BoundColumn DataField="pecas" HeaderText="N&#250;mero de pe&#231;as"></asp:BoundColumn>
                    <asp:BoundColumn DataField="total" HeaderText="Total" DataFormatString="R$ {0}"></asp:BoundColumn>
                </Columns>
            </asp:DataGrid>
            <!-- Insert content here -->
        </p>
    </form>
</body>
</html>
